package com.transaction.manage.controller;

import com.transaction.common.base.BaseController;
import com.transaction.common.base.ResultVo;
import com.transaction.manage.service.TaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ta")
@Api(value = "TA操作接口类", tags = {"ta操作的相关接口"})
public class TaController extends BaseController {

    private static Logger LOGGER = LoggerFactory.getLogger(TaController.class);

    @Autowired
    private TaService taService;

    /**
     * 生成TA产品的净值或者万份收益和七日年化
     * @return
     */
    @ApiOperation(value = "生成TA产品的收益",
            notes = "生成TA产品的净值或者万份收益和七日年化", httpMethod = "POST")
    @PostMapping("/createTaFundIncome")
    public Object createTaFundIncome(){
        LOGGER.info("生成TA产品的净值或者万份收益和七日年化");
        taService.createTaFundNetValueAndIncome();
        return retResultVo("生成成功");
    }

    /**
     * 查询TA产品的每天的收益信息
     * @return
     */
    @ApiOperation(value = "查询TA产品的收益信息",
            notes = "查询TA产品的净值或者万份收益和七日年化", httpMethod = "GET")
    @GetMapping("/getTaFundIncome")
    public Object getCrmFundDay(@ApiParam(name = "date",value = "查询的时间",defaultValue = "2022-05-20", required = false)
                                    @RequestParam String date){
        LOGGER.info("查询TA产品的净值或者万份收益和七日年化");
        return retResultVo(taService.getCrmFundDay(date));
    }

}
